#ifndef CASHFACTORY_H
#define CASHFACTORY_H

#include "cash.h"

#include <stdexcept>

class CashFactory
{
public:
    static Cash *createCashMode(int mode)
    {
        Cash *cash = nullptr;
        switch (mode)
        {
        case 1:
            cash = new CashNormal();
            break;
        case 2:
            cash = new CashDiscount(0.8);
            break;
        case 3:
            cash = new CashDiscount(0.7);
            break;
        case 4:
            cash = new CashRebate(300, 100); // 满300返100
            break;
        default:
            throw std::invalid_argument("选择的模式无效");
            break;
        }

        return cash;
    }
};

#endif